package com.zerdoor.util;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;

public class SpringSimpleEmail {
    public static void main(String[] args) {
//        try {
//            ApplicationContext ctx = new ClassPathXmlApplicationContext("conf/spring-mvc.xml");
//            JavaMailSender sender = (JavaMailSender)ctx.getBean("javaMailSender");
//            MimeMessage msg = sender.createMimeMessage();
//            MimeMessageHelper helper = new MimeMessageHelper(msg,true,"utf-8");
//            //helper.setFrom("xxxxxxx@qq.com");
//            helper.setTo("angus584@qq.com");
//            helper.setText("tets this is a spring mvc email");
//            helper.setSubject("xxxxxxx");
//            sender.send(msg);
//            System.out.println("email send ok");
//
//        } catch (MessagingException e) {
//            System.out.println("send fail");
//            e.printStackTrace();
//        }

    }
}
